﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Diagnostics;
using SBACN.WebSite.Models;
using System.Linq.Expressions;
using System.Threading;
using System.Data;
using SBACN.WebSite.Common;

namespace SBACN.WebSite
{
	public partial class Test : System.Web.UI.Page
	{
		Stopwatch sw = new Stopwatch();
		protected void Page_Load(object sender, EventArgs e)
		{
            //sw.Restart();
            //if(!Page.IsPostBack)
            //{
            //    TestThread();
            //}
			//Mail.Instance.SendEMail("TestTitle测试","TestBody测试","abeyondme@hotmail.com");
		}

		private void TestThread()
		{
            //using (var _entityContext = new SBACNEntities())
            //{
            //    for (int i = 0; i < 10; i++)
            //    {
            //        //EntityKey entityKey = new EntityKey("SBACNEntities." + typeof(TB_AdminRight).Name, "ID", 1);
            //        //object returnObject = null;
            //        //TB_AdminRight returnInstance = null;
            //        //if (_entityContext.TryGetObjectByKey(entityKey, out returnObject))
            //        //{
            //        //    returnInstance = returnObject as TB_AdminRight;
            //        //}
            //    }
            //    //Thread t = new Thread(ThreadWork);
            //    //t.Start();
            //}
            //long m = sw.ElapsedMilliseconds;
            //this.lbl_Msg.Text += "测试;耗时:" + m + "毫秒<br />";
		}

		private void ThreadWork()
		{
			//DAL.DALHelper.Instance.GetObject<TB_AdminRight>("ID", 1);
		}

		protected void btn_Test1_Click(object sender, EventArgs e)
        {
        //{
        //    int rounds = 0;
        //    if (int.TryParse(txt_TestRounds.Text, out rounds))
        //    {
        //        //for (int i = 0; i < rounds; i++)
        //        //{
        //        //    Expression<Func<TB_AdminRight,bool>> f = (p => p.ID == (i % 10 + 1));
        //        //    DAL.DALHelper.Instance.GetFirstOrDefaultObject<TB_AdminRight>(f);
        //        //}
        //        long m = sw.ElapsedMilliseconds;
        //        this.lbl_Msg.Text += "测试1:" + rounds + "轮;耗时:" + m + "毫秒<br />";
        //    }
		}

		protected void btn_Test2_Click(object sender, EventArgs e)
		{
            //int rounds = 0;
            //if(int.TryParse(txt_TestRounds.Text,out rounds))
            //{
            //    for (int i = 0; i < rounds; i++)
            //    {
            //        //DAL.DALHelper.Instance.GetObject<TB_AdminRight>("ID", i % 10 + 1);
            //    }
            //    long m = sw.ElapsedMilliseconds;
            //    this.lbl_Msg.Text += "测试2:" + rounds + "轮;耗时:" + m + "毫秒<br />";
            //}
		}
	}
}